MSP430之 | 您所在的位置:网站首页 › in range函数是什么意思 › MSP430之 |
MSP430之__even_in_range
转自:http://lfwendula0.blog.163.com/blog/static/205138236201272973147213/
使用__even_in_range 的好处是可以生成效率比较高的代码,在判断多中断源的中断的来源时可以使用此函数。
原型:unsigned short __even_in_range(unsigned short value, unsignedshort upper_limit); 功能:只能与switch 语句结合使用,判断value 是否为偶数且小于等于upper_limit。 举例: #pragma vector=PORT1_VECTOR __interrupt void PORT1_ISR(void) //ISR Interrupt Service Routine中断服务程序;IRQ Interrupt Request中断请求 { switch(__even_in_range(P1IV, 16)) { case 0: break; case 2: break; // P1.0 IFG case 4: break; // P1.1 IFG case 6: break; // P1.2 IFG case 8: break; // P1.3 IFG case 10: break; // P1.4 IFG case 12: break; // P1.5 IFG case 14: break; // P1.6 IFG case 16: // P1.7 IFG __bic_SR_register_on_exit(LPM3_bits); // Exit active break; } } 结果:假设P1IV 的值为16,执行 __bic_SR_register_on_exit(LPM3_bits);。否则,与普通的switch 语句一样,跳过case 部分,直接执行下面的程序。
|
CopyRight 2018-2019 实验室设备网 版权所有 |